
import SwiftUI
import Speech
/*
struct RecordingView: View {
   @State private var isRecording = false
   @State private var isEditing = false
   @State private var recordingText = ""
   
   var body: some View {
       VStack {
           Spacer()
           Text(recordingText)
               .font(.title)
               .foregroundColor(.black)
               .padding()
           Spacer()
           HStack {
               Spacer()
               Button(action: {
                   self.isRecording.toggle()
                   if self.isRecording {
                       // Start recording
                       // Start speech-to-text conversion
                   } else {
                       // Stop recording
                       // Stop speech-to-text conversion
                   }
               }) {
                   Image(systemName: isRecording ? "stop.circle.fill" : "mic.circle.fill")
                       .resizable()
                       .frame(width: 80, height: 80)
                       .foregroundColor(.red)
                       .padding()
                       .overlay(
                           Circle()
                               .stroke(Color.red, lineWidth: 5)
                               .opacity(isRecording ? 1 : 0)
                               .scaleEffect(isRecording ? 1 : 0.1)
                               .animation(.easeInOut(duration: 0.5))
                       )
               }
               Spacer()
           }
           Spacer()
       }
       .overlay(
           HStack {
               Spacer()
               Button(action: {
                   // Cancel recording
               }) {
                   Image(systemName: "xmark.circle.fill")
                       .resizable()
                       .frame(width: 40, height: 40)
                       .foregroundColor(.red)
                       .padding()
                       .opacity(isRecording ? 1 : 0)
                       .scaleEffect(isRecording ? 1 : 0.1)
                       .animation(.easeInOut(duration: 0.5))
               }
               Spacer()
               Button(action: {
                   self.isEditing.toggle()
                   // Stop recording
                   // Stop speech-to-text conversion
               }) {
                   Image(systemName: "pencil.circle.fill")
                       .resizable()
                       .frame(width: 40, height: 40)
                       .foregroundColor(.red)
                       .padding()
                       .opacity(isRecording ? 1 : 0)
                       .scaleEffect(isRecording ? 1 : 0.1)
                       .animation(.easeInOut(duration: 0.5))
               }
               Spacer()
           }
           , alignment: .bottom
       )
   }
}

struct RecordingView_Previews: PreviewProvider {

//    static var testAddBill = AddBill.testAddBills()
    static var previews: some View {
        RecordingView()
    }
}
*/


struct RecordingView: View {
    @State private var isRecording = false
    @State private var isEditing = false
    @State private var recordingText = ""
    
    var body: some View {
        VStack {
            Spacer()
            Text(recordingText)
                .font(.title)
                .foregroundColor(.black)
                .padding()
            Spacer()
            HStack {
                Spacer()
                Button(action: {
                    self.isRecording.toggle()
                    if self.isRecording {
                        // Start recording
                        // Start speech-to-text conversion
                    } else {
                        // Stop recording
                        // Stop speech-to-text conversion
                    }
                }) {
                    Image(systemName: isRecording ? "stop.circle.fill" : "mic.circle.fill")
                        .resizable()
                        .frame(width: 80, height: 80)
                        .foregroundColor(.red)
                        .padding()
                        .overlay(
                            Circle()
                                .stroke(Color.red, lineWidth: 5)
                                .opacity(isRecording ? 1 : 0)
                                .scaleEffect(isRecording ? 1 : 0.1)
                                .animation(.easeInOut(duration: 0.5))
                        )
                }
                Spacer()
            }
            Spacer()
        }
        .overlay(
            HStack {
                Spacer()
                Button(action: {
                    // Cancel recording
                }) {
                    Image(systemName: "xmark.circle.fill")
                        .resizable()
                        .frame(width: 40, height: 40)
                        .foregroundColor(.red)
                        .padding()
                        .opacity(isRecording ? 1 : 0)
                        .scaleEffect(isRecording ? 1 : 0.1)
                        .animation(.easeInOut(duration: 0.5))
                }
                Spacer()
                Button(action: {
                    self.isEditing.toggle()
                    // Stop recording
                    // Stop speech-to-text conversion
                }) {
                    Image(systemName: "pencil.circle.fill")
                        .resizable()
                        .frame(width: 40, height: 40)
                        .foregroundColor(.red)
                        .padding()
                        .opacity(isRecording ? 1 : 0)
                        .scaleEffect(isRecording ? 1 : 0.1)
                        .animation(.easeInOut(duration: 0.5))
                }
                Spacer()
            }
            , alignment: .bottom
        )
        .simultaneousGesture(LongPressGesture(minimumDuration: 1.0).onEnded { _ in
            self.isRecording.toggle()
            if self.isRecording {
                // Start recording
                // Start speech-to-text conversion
            } else {
                // Stop recording
                // Stop speech-to-text conversion
            }
        })
        .simultaneousGesture(DragGesture(minimumDistance: 0).onEnded { _ in
            if self.isRecording {
                // Cancel recording
            } else {
                self.isEditing.toggle()
                // Stop recording
                // Stop speech-to-text conversion
            }
        })
    }
}


struct RecordingView_Previews: PreviewProvider {

//    static var testAddBill = AddBill.testAddBills()
    static var previews: some View {
        RecordingView()
    }
}

